package org.cometmi.gwt.echo1.server;

import org.apache.log4j.Logger;
import org.cometmi.gwt.echo1.shared.MyTestObject;
import org.cometmi.gwt.server.annotation.ClassMiHandler;
import org.cometmi.gwt.server.events.MiEvent;
import org.cometmi.gwt.server.events.MiEventHandler;
import org.cometmi.gwt.shared.exceptions.InvalidArgumentException;

@ClassMiHandler(objectClass = MyTestObject.class, parameterTypes = { String.class }, allowedQueues = { "org.cometmi.gwt.test.echo1" })
public class Echo1ConstrHandler implements MiEventHandler
{
	static protected Logger logger = Logger.getLogger(Echo1ConstrHandler.class);

	@Override
	public void onBeforeMethod(MiEvent event)
	{
		try
		{
			String arg = event.getMethodArgument(String.class, 0);
			logger.info("constructor argument: " + arg);
			event.setMethodArgument(arg + " from server", 0);
		}
		catch (InvalidArgumentException e)
		{
			e.printStackTrace();
		}
	}

	@Override
	public void onAfterMethod(MiEvent event)
	{}
}
